# Make iTextUploader full package
# Revision: $Id: makefile 113 2009-04-16 18:27:43Z myselftdev $

.SILENT:

all:	compile-bundle

compile-bundle:
	echo "Running make in itextuploader/"
	cd itextuploader; make
	echo "\nRunning make in itextuploader-lite/"
	cd itextuploader-lite; make
	echo "\nMaking final application bundle"
	echo "(It's safe to ignore errors from rm here)"
	-rm -R iTextUploader.app
	cp -pR itextuploader/iTextUploader.app iTextUploader.app
	cp -p itextuploader-lite/iTextUploader-lite iTextUploader.app
	cp -p itextuploader-lite/service iTextUploader.app
	cp -p itextuploader/LICENSE-* iTextUploader.app
	cp -p itextuploader-lite/LICENSE-* iTextUploader.app
	echo "\nApplication bundle ready"

package:
	echo "\nMaking deb package"
	echo "\nPreparing folders"
	echo "(It's safe to ignore errors from rm here)"
	-rm -R deb/
	mkdir deb
	mkdir deb/Applications
	mkdir deb/System
	mkdir deb/System/Library
	mkdir deb/System/Library/LaunchDaemons
	mkdir deb/DEBIAN
	echo "Putting files into right place"
	cp -pR iTextUploader.app deb/Applications/iTextUploader.app
	chown root:wheel deb/Applications/iTextUploader.app/service
	chown root:wheel deb/Applications/iTextUploader.app/autoupload.plist
	chown root:wheel deb/Applications/iTextUploader.app/itextuploader-startup.plist
	cp -p deb/Applications/iTextUploader.app/itextuploader-startup.plist deb/System/Library/LaunchDaemons
	cp -p itextuploader/control deb/DEBIAN
	cp -p itextuploader/extrainst_ deb/DEBIAN
	chmod +x deb/DEBIAN/extrainst_
	cp -p itextuploader/prerm deb/DEBIAN
	chmod +x deb/DEBIAN/prerm
	echo "Let dpkg build the package"
	echo "(ignoring errors about invalid fields in the control file is safe - those are fields added by Cydia extensions)"
	export COPYFILE_DISABLE; export COPY_EXTENDED_ATTRIBUTES_DISABLE; dpkg -b deb itextuploader.deb
	echo "Deb package built!"

clean:
	cd itextuploader; make clean
	cd itextuploader-lite; make clean
	-rm -R iTextUploader.app
	-rm -R deb
	-rm itextuploader.deb